﻿using System;
using System.Collections.Generic;

namespace RxPowerToys.JobQueues
{
    public interface IJobQueue
    {
        IObservable<Notification<Unit>> WhenJobCompletes { get; }
        IObservable<Unit> WhenQueueEmpty { get; }
        IObservable<Exception> WhenJobFails { get; }

        int RunningCount { get; }
        int QueuedCount { get; }

        IObservable<Unit> Add(Action action);
        IObservable<Unit> Add(Func<IObservable<Unit>> asyncStart);

        bool StartNext();
        int StartUpTo(int maxConcurrentlyRunning);

        void CancelOutstandingJobs();
    }
}
